package
{
	import flash.display.DisplayObjectContainer;
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.net.SharedObject;

	public class InitializationManager extends EventDispatcher
	{		
		private var m_stage:Stage;
		public function InitializationManager(stage:Stage)
		{
			Global.stage = m_stage = stage;
			Global.inputManager = new InputManager(m_stage);
			var store:GameObject;
			
			Global.isoScene.addChild(Global.createGrid());
			
			Global.isoView.addScene(Global.isoScene);
			m_stage.addChild(Global.isoView);
			

			
			Global.actionBarManager = new ActionBarManager();
			var actionBarDisplay:Sprite = Global.actionBarManager.getActionBarDisplay();
			actionBarDisplay.y = m_stage.height - actionBarDisplay.height;
			actionBarDisplay.x = 0;
			m_stage.addChild(actionBarDisplay);
			
			
			m_stage.addChild(Global.player.getDebugDisplay());
			
			var so:SharedObject = SharedObject.getLocal("Game");
			var playerData:Object = so.data.player;
			if(playerData){
				Global.player.wakeup(playerData);	
			}
			
			Global.pathManager.showDebugRendering();
		}
		
		public function start():void{
			dispatchEvent(new Event(Event.COMPLETE));
		}
	}
}